package com.baoyang.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baoyang.entity.ProductName;
import com.baoyang.mapper.ProductNameMapper;
import com.baoyang.service.IProductNameService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 金佳军
 * @since 2025-07-08
 */
@Service
public class ProductNameServiceImpl extends ServiceImpl<ProductNameMapper, ProductName> implements IProductNameService {

    @Resource
    private ProductNameMapper productNameMapper;

    @Override
    public IPage<ProductName> pageUserList(Page<ProductName> page, String name) {
        QueryWrapper<ProductName> queryWrapper = new QueryWrapper<>();
        if (name != null && !name.trim().isEmpty()) {
            queryWrapper.like("name", name);
        }
        queryWrapper.orderByDesc("create_time");
        return productNameMapper.selectPage(page, queryWrapper);
    }
}
